package com.heshida.controller;

import com.heshida.po.Orders;
import com.heshida.service.OrdersService;
import com.heshida.service.impl.OrdersServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@RestController
@RequestMapping("/OrdersController")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;

    @RequestMapping("/createOrders")
    public int createOrders(String userId, Integer businessId, Integer daId){


        int rows = ordersService.createOrders(userId, businessId, daId);
        return rows;
    }

    @RequestMapping("/getOrderById")
    public Orders getOrdersById(Integer orderId) {
        return ordersService.getOrdersById(orderId);
    }

    @RequestMapping("/listOrderByUserId")
    public List<Orders> listOrderByUserId(String userId){

        List<Orders> list = ordersService.listOrderByUserId(userId);
        return list;
    }

    @RequestMapping("/updateOrderStatusById")
    public int updateOrdersStatusById(int orderId){
        return ordersService.updateByOrderId(orderId);
    }
}
